<?php
/**
 * 
 */
namespace app\manage\controller\score;

use app\manage\controller\Base;

class Api extends Base
{
	/**
	 * 系统新增业绩
	 * @return [type] [description]
	 */
	public function score(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('member_score')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);

	}

	/**
	 * 业绩明细
	 * @return [type] [description]
	 */
	public function record(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('member_score_record')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);
	}

	/**
	 * 每日新增业绩
	 * @return [type] [description]
	 */
	public function daily(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key']);
        }

        $data = model('member_score_daily')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);
	}



	// public function score(){
		
	// 	$params = $this->request->param();
	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);
		
	// 	$query = new \app\common\query\MemberScore;

	// 	$data = $query->getRows($where,$queryStr,url('score.show/index'));
	// 	return json($data);

	// }

	// public function record(){
		
	// 	$params = $this->request->param();
	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);

	// 	$query = new \app\common\query\MemberScoreRecord;

	// 	$data = $query->getRows($where,$queryStr,url('score.show/record'));
	// 	return json($data);

	// }

	// public function daily(){
		
	// 	$params = $this->request->param();
	// 	$where = $params;
	// 	unset($where['page']);
	// 	// 去除空值参数
	// 	$where = filterArrEmptyItem($where);
	// 	$queryStr = $where?'&'.parseQuery($where):'';
	// 	$where = parseWhere($where);

	// 	$query = new \app\common\query\MemberScoreDaily;

	// 	$data = $query->getRows($where,$queryStr,url('score.show/daily'));
	// 	return json($data);

	// }


}